import {FC, useMemo} from 'react';
import {RouteComponentProps} from 'react-router'
import _ from 'lodash';
import {WithNormalRender} from '@/biz-components/hoc-form/with-normal';
import api from './services';
import {onFieldInit, onFormMount} from '@formily/core';
import {
    useBillParams
} from '@/pages/invoice/hooks';
import {Form} from "@formily/core/lib/models";
import {xhrPostJson} from "@/services";

interface ArchivesMngDetailProps {
}

const PzDetail: FC<ArchivesMngDetailProps> = (props) => {

    const {businessNo, businessType} = props;
    const pageCode = businessType


    // const { arcvCode, arcvType, arfbCode } = params as any ;

    const detailApi: any = useMemo(() => {
        return {
            remoteUrl: "/arcv/mof/pageConfig/getPageConfigByPageCodeFront",
            // method: 'POST',
            remoteParams: {
                refCode: businessNo
            },
            pageCode,
        };
    }, [pageCode]);

    const initValue = (form: Form<any>) => {
        xhrPostJson(api.rcptDetail, {
            refCode: businessNo,
            pageCode
        }).then((res: any) => {
            if (res.success) {
                form.setValues({...res.result})
            }
        })
    }

    const BillFormLayout = useMemo(() => {
        return WithNormalRender({});
    }, []);

    return (
        <BillFormLayout
            anchor
            type="DETAIL"
            {...detailApi}
            formConfigs={{
                effects: () => {
                    onFormMount((form) => {
                        initValue(form);
                    })
                    onFieldInit('arcvItems.operations', field => {
                        field.visible = false;
                    })
                }
            }}
            filedConfig={{}}
        />
    );
};

export default PzDetail;
